package util;

import entry.Books;

import java.util.ArrayList;

public class PageHelper {
    private Integer perPage = 3;
    private Integer allNum;
    private Integer pageNum;
    private Integer whichPage = 1;
    private ArrayList<Books> list;

    public PageHelper() {
    }

    public PageHelper(Integer perPage, Integer allNum, Integer pageNum, Integer whichPage, ArrayList<Books> list) {
        this.perPage = perPage;
        this.allNum = allNum;
        this.pageNum = pageNum;
        this.whichPage = whichPage;
        this.list = list;
    }

    @Override
    public String toString() {
        return "PageHelper{" +
                "perPage=" + perPage +
                ", allNum=" + allNum +
                ", pageNum=" + pageNum +
                ", whichPage=" + whichPage +
                ", list=" + list +
                '}';
    }

    public Integer getPerPage() {
        return perPage;
    }

    public void setPerPage(Integer perPage) {
        this.perPage = perPage;
    }

    public Integer getAllNum() {
        return allNum;
    }

    public void setAllNum(Integer allNum) {
        this.allNum = allNum;
        if (allNum % this.getPerPage() == 0)
            this.setPageNum(allNum / this.getPerPage());
        else
            this.setPageNum(allNum / this.getPerPage() + 1);
    }

    public Integer getPageNum() {
        return pageNum;
    }

    private void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getWhichPage() {
        return whichPage;
    }

    public void setWhichPage(Integer whichPage) {
        this.whichPage = whichPage;
    }

    public ArrayList<Books> getList() {
        return list;
    }

    public void setList(ArrayList<Books> list) {
        this.list = list;
    }
}
